<?php
/**
 * RabbitCMS
 * 
 * LICENSE
 *
 * This source file is subject to the GNU GENERAL PUBLIC LICENSE Version 2 
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://www.gnu.org/licenses/gpl-2.0.txt
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@tomatocms.com so we can send you a copy immediately.
 * 
 * @copyright	Copyright (c) 2009-2010 TIG Corporation (http://www.tig.vn)
 * @license		http://www.gnu.org/licenses/gpl-2.0.txt GNU GENERAL PUBLIC LICENSE Version 2
 * @version 	$Id: show.phtml 5399 2010-09-12 17:49:50Z huuphuoc $
 * @since		2.0.9
 */
?>
<?php
$count = count($this->categories);
$rightStack = array();
?>
<div id="template-categories">
    <h2 class="tc-title"><?php echo $this->translate()->widget('title')?></h2>
    <ul>
    <?php
    if($count > 0){
        for ($i = 0; $i < $count; $i++) {
            while (count($rightStack) > 0 && $rightStack[count($rightStack) - 1] < $this->categories[$i]->rht) {
                array_pop($rightStack);
            }
    ?>
        <li id="category-<?php echo $this->categories[$i]->id ?>" <?php if ($i == $count - 1) echo 'class="last"'; ?>>
            <a  href="<?php echo $this->url($this->categories[$i]->getProperties(), 'product_product_category')?>">
                <span><?php echo str_repeat('&mdash;', count($rightStack) + 1)?></span>
                <?php echo $this->categories[$i]->name?>
            </a>
        </li>
    <?php
            $rightStack[] = $this->categories[$i]->rht;
        }
    }                          
?>
    </ul>
</div>
<script type="text/javascript">
$(document).ready(function(){
        var right = $('#main').offset().left + $('#template-categories ul').width();
        $('#template-categories').width(right + 10);
        $('#template-categories ul li').css('padding-left', ($('#main').offset().left + 10) + 'px');
        $('#template-categories h2.tc-title').css({
            paddingLeft: ($('#main').offset().left + 45)+ 'px',
            backgroundPosition: ($('#main').offset().left + 5)+ 'px 2px'
        });
        var height = $('#template-categories').height()
            +  parseInt($('#template-categories').css('margin-top'))
            +  parseInt($('#template-categories').css('margin-bottom'))
            +  parseInt($('#template-categories').css('padding-top'))
            +  parseInt($('#template-categories').css('padding-bottom'));

        $('#m-left').css({paddingTop: height + 10});
        if($('#main').height() < $('#template-categories').height()){
            $('#main').height(height);
        }
});
</script>